HomeController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 23
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A get 0 10 1
A index 0 5 1
1
import {
2
  Controller,
3
  Get,
4
  Inject,
5
  Render,
6
  Res,
7
  UseGuards
8
} from '@nestjs/common';
9
import { Response } from 'express';
10
import { GetPendingLeaveRequestsCountQuery } from 'src/Application/HumanResource/Leave/Query/GetPendingLeaveRequestsCountQuery';
11
import { IQueryBus } from 'src/Application/IQueryBus';
12
import { RouteNameResolver } from 'src/Infrastructure/Common/ExtendedRouting/RouteNameResolver';
13
import { WithName } from 'src/Infrastructure/Common/ExtendedRouting/WithName';
14
import { IsAuthenticatedGuard } from 'src/Infrastructure/HumanResource/User/Security/IsAuthenticatedGuard';
15
16
@Controller()
17
@UseGuards(IsAuthenticatedGuard)
18
export class HomeController {
19
  constructor(
20
    private readonly resolver: RouteNameResolver,
21
    @Inject('IQueryBus')
22
    private readonly queryBus: IQueryBus
23
  ) {}
24
25
  @Get('app')
26
  @WithName('home')
27
  @Render('pages/home.njk')
28
  public async get() {
29
    const pendingLeaves = await this.queryBus.execute(
30
      new GetPendingLeaveRequestsCountQuery()
31
    );
32
33
    return { pendingLeaves };
34
  }
35
36
  @Get()
37
  @WithName('index')
38
  public index(@Res() res: Response) {
39
    res.redirect(303, this.resolver.resolve('home'));
40
  }
41
}
42